<!doctype html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>确认订单</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wx/css/base.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wx/css/detail.css" />
</head>
<body>
<div class="detail">
    <div class="state">
        <switch name="wholesale['state']">
            <case value="3">
                <!--待付款-->
                <div class="inner">
                    <h2 style="padding-top:0;">等待买家付款</h2>
                    <span><img src="__PUBLIC__/Wx/img/icon04.png"/></span>
                </div>
            </case>
            <case value="2">
                <!--待发货-->
                <div class="inner">
                    <h2 style="padding-top:0;">买家已付款</h2>
                    <span><img src="__PUBLIC__/Wx/img/icon19.png"/></span>
                </div>
            </case>
            <case value="4">
                <!--待收货-->
                <div class="inner">
                    <h2>农户已发货</h2>
                    <span><img src="__PUBLIC__/Wx/img/icon06.png"/></span>
                </div>
            </case>
            <case value="5">
                <!--待评价-->
                <div class="inner">
                    <h2>交易成功</h2>
                    <span><img src="__PUBLIC__/Wx/img/icon33.png"/></span>
                </div>
            </case>
        </switch>
    </div>
    <div class="address">
        <div class="add" style="background:none;">
            <a href="javascript:0;">
                <h3><span>{$wholesale.name}</span><span>{$wholesale.mobile}</span></h3>
                <p>收货地址：{$wholesale.address}</p>
            </a>
        </div>
    </div>
    <div class="prolist">
        <div class="pro" onClick="window.location='__MODULE__/Wholesale/prodetail/id/{$wholesale.g_id}'">
            <div class="pic"><img src="<?=isMorePic($wholesale['store']['h_imgs'])?>"/></div>
            <div class="name">
                <h2>{$wholesale.store.title} {$wholesale.store.u_num}<?=getunit($wholesale['store']['unit'])?></h2>
                <p><b><img src="{$wholesale.member.avatar}"/></b><i>{$wholesale.member.nickname}</i><em>{$wholesale.village}</em></p>
                <h3><del>原价：{$wholesale.store.price}</del><em>￥{$wholesale.price}</em><i>（{$wholesale.price_range.start}-{$wholesale.price_range.end}件）</i><b>X{$wholesale.num}</b></h3>
            </div>
        </div>
        <div class="total">共<b>1</b>件商品<span>合计：<i>￥{$wholesale.price_all}+{$wholesale.price_charge}</i></span></div>
        <div class="button05">
            <switch name="wholesale['state']">
                <case value="3">
                    <input type="button" class="delete" value="取消订单" style="background:#fff; border:1px #666666 solid; margin-right:10px; color:#666;"/><input type="button" value="立即付款" onClick="pay()"/>
                </case>
                <case value="2">
                    <input type="button" value="提醒发货" onclick="deliver()" style="background:#fff; border:1px #666666 solid;color:#666;"/>
                </case>
                <case value="4">
                    <input type="button"  value="查看物流" style="background:#fff; border:1px #666666 solid; margin-right:10px; color:#666;"  onClick="window.location='__MODULE__/WholesaleOrder/logistics'"/>
                    <input type="button" value="确认收货" onclick="take()"/>
                </case>
                <case value="5">
                    <input type="button"  value="查看物流" style="background:#fff; border:1px #666666 solid; margin-right:10px; color:#666;"  onClick="window.location='__MODULE__/WholesaleOrder/logistics'"/><input type="button" value="发表评价" onClick="window.location='__MODULE__/WholesaleOrder/addEva/wid/{$wholesale['id']}'"/>
                </case>
            </switch>
        </div>
    </div>
    <div class="ordermess">
        <p>订单编号：{$wholesale.order_sn}</p>
        <p>创建时间：<?=date("Y-m-d H:i:s",$wholesale['addtime'])?></p>
    </div>
    <div class="notes">
        <div class="inner">
            <h2><img src="__PUBLIC__/Wx/img/success03.png"/></h2>
            <h3>取消成功！</h3>
        </div>
    </div>

</div>

<script type="text/javascript" src="__PUBLIC__/Wx/js/jquery-1.9.1.js"></script>
<script type="text/javascript">
    $(".click span").click(function(){
        if($(this).text() ==="导航"){
            $(this).text("收起");
            $('.link02').css('display','block')
        }else{
            $(this).text("导航");
            $('.link02').css('display','none')
        }//end if
    });//end fun
</script>
<script type="text/javascript">
    //支付订单
    function pay() {
        var id = "{$wholesale['id']}";
        $.post("__MODULE__/WholesaleOrder/pay",{"id":id},function (d) {
            console.log(d);
            if(d.state > 0){
                $(".inner").children('h3').text(d.val);
                $(".notes").css('display','block');
            }else{
                window.location.href="http://www.xiangtws.com/index.php/Api/Salepay/choosePay/pay_id/"+d.id;
            }//end if
        });//end post
    }//end fun

    //删除订单
    $(".delete").click(function(){
        var id = "{$wholesale['id']}";
        $.post("__MODULE__/WholesaleOrder/delete",{"id":id},function (d) {
            if(d.state>0){
                $(".inner").children('h3').text("取消失败!");
                $(".notes").css('display','block');
                $('.notes').delay(3000).hide(0);
            }else{
                window.location.href="__MODULE__/WholesaleOrder/index";
            }//end if
        });//end post
    });//end fun

    //提醒发货
    function deliver() {
        var id = "{$wholesale['id']}";
        $.post("__MODULE__/WholesaleOrder/deliver",{"id":id},function (d) {
            console.log(d);
            if(d.state > 0){
                $(".inner").children('h3').text(d.val);
                $(".notes").css('display','block');
                $('.notes').delay(3000).hide(0);
            }else{
                $(".inner").children('h3').text(d.val);
                $(".notes").css('display','block');
                $('.notes').delay(3000).hide(0);
            }//end if
        });//end post
    }//end fun

    //确认收货
    function take() {
        var id = "{$wholesale['id']}";
        $.post("__MODULE__/WholesaleOrder/take",{"id":id},function (d) {
            console.log(d);
            if(d.state > 0){
                $(".inner").children('h3').text(d.val);
                $(".notes").css('display','block');
                $('.notes').delay(3000).hide(0);
            }else{
                window.location.reload();
            }//end if
        });//end post
    }//end fun
</script>
</body>
</html>